React Clean Code by Juntao Qiu

React Clean Code by Juntao Qiu

Author:Juntao Qiu
Language: eng
Format: epub, pdf


And once it’s done, we have our new function formatCheckboxLabelas:

1 export function formatCheckboxLabel( 2 agreeToDonate: boolean, 3 tip: number, 4 countryCode: string 5 ) { 6 const currencySign = countryCode === "JP" ? "Â¥" : `$`; 7 8 return agreeToDonate 9 ? "Thanks for your donation." 10 : `I would like to donate ${currencySign}${tip} to ch\ 11 arity.`; 12 }

Also, don’t forget to update the calling place too in Payment.tsx

Extract Function

And one last thing in Payment is that we have to update the button label with the current currency sign:

1 <button className="payment-button">${total}</button>



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.